/*
 * @Author: malgee
 * @Date: 2025-04-23 15:37:32
 * @LastEditors: maling
 * @LastEditTime: 2025-04-27 17:05:06
 * @FilePath: /vue3-ts-cms/src/mock/login/login.ts
 * @Description: 
 * 
 */

import { useJsonService, JsonData } from '@/serviceJson/jsonService'
class LoginMock {
  
  error?: string | null
  loading?: boolean
  fetchJson?: (filePath: string) => Promise<JsonData | null>
  saveJson?: (filePath: string, data: JsonData) => void

  constructor() {
    const { error, loading, fetchJson, saveJson } = useJsonService();
    this.error = error.value
    this.loading = loading.value
    this.fetchJson = fetchJson
    this.saveJson = saveJson
  }

  loginData(params?: any): Promise<JsonData | null> {
    if (!this.fetchJson) {
      return Promise.resolve(null)
    }
    return this.fetchJson('/json/login.json')
  }
  
  userInfo(params?: any): Promise<JsonData | null> {
    if (!this.fetchJson) {
      return Promise.resolve(null)
    }
    return this.fetchJson('/json/userInfo.json')
  }

  userList(params?: any): Promise<JsonData | null> {
    if (!this.fetchJson) {
      return Promise.resolve(null)
    }
    return this.fetchJson('/json/userList.json')
  }

  userMenus(params?: any): Promise<JsonData | null> {
    if (!this.fetchJson) {
      return Promise.resolve(null)
    }
    return this.fetchJson('/json/userMenus.json')
  }

  roleList(params?: any): Promise<JsonData | null> {
    if (!this.fetchJson) {
      return Promise.resolve(null)
    }
    return this.fetchJson('/json/roleList.json')
  }

  departmentList(params?: any): Promise<JsonData | null> {
    if (!this.fetchJson) {
      return Promise.resolve(null)
    }
    return this.fetchJson('/json/departmentList.json')
  }

  menuList(params?: any): Promise<JsonData | null> {
    if (!this.fetchJson) {
      return Promise.resolve(null)
    }
    return this.fetchJson('/json/menuList.json')
  }
}

export default new LoginMock()
